<template>
  <el-row type="flex" justify="center" :gutter="32">
    <el-col :span="6">
      <el-card>
        <div class="card-panel">
          <i style="color: #40c9c6" class="fas fa-users card-panel-icon" />
          <div class="card-desc">
            <div class="card-desc-title">访问量</div>
            <div class="card-desc-info"> <count-to :start-val="0" :end-val="cardPanelData.visits_count" :duration="2000" /> </div>
          </div>
        </div>
      </el-card>
    </el-col>
    <el-col :span="6">
      <el-card>
        <div class="card-panel">
          <i style="color: #E6A23C" class="fas fa-file-alt card-panel-icon" />
          <div class="card-desc">
            <div class="card-desc-title">文章数</div>
            <div class="card-desc-info"> <count-to :start-val="0" :end-val="cardPanelData.articles_count" :duration="2000" /></div>
          </div>
        </div>
      </el-card>
    </el-col>
    <el-col :span="6">
      <el-card>
        <div class="card-panel">
          <i style="color: #36a3f7" class="fas fa-comment-dots card-panel-icon" />
          <div class="card-desc">
            <div class="card-desc-title">留言量</div>
            <div class="card-desc-info"><count-to :start-val="0" :end-val="cardPanelData.messages_count" :duration="2000" /></div>
          </div>
        </div>
      </el-card>
    </el-col>
    <el-col :span="6">
      <el-card>
        <div class="card-panel">
          <i style="color: #0482f1" class="fas fa-comments card-panel-icon" />
          <div class="card-desc">
            <div class="card-desc-title">评论数量</div>
            <div class="card-desc-info"><count-to :start-val="0" :end-val="cardPanelData.comments_count" :duration="2000" /></div>
          </div>
        </div>
      </el-card>
    </el-col>
  </el-row>
</template>

<script>
import CountTo from 'vue-count-to'
export default {
  name: 'CardPanel',
  components: {
    CountTo
  },
  props: {
    cardPanelData: {
      type: Object,
      required: true
    }
  }
}
</script>

<style scoped>
  .card-panel {
    display: flex;
    justify-content: space-between;
  }

  .card-panel-icon {
    font-size: 4rem;
    color: #85dbb2;
  }

  .card-desc {
    float: right;
    text-align: center;
    font-weight: 700;
    line-height: 1.55;
    font-size: 1.2rem;
  }

  .card-desc-title {
    color: #8c8c8c;
  }

  .card-desc-info {
    color: #666666;
  }
</style>
